package com.chixing.day13.day13_Home;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;

public class ProductTest {
    public static void main(String[] args){
        HashSet<Product> products = new HashSet<>();

          //1
          products.add(new Product(101,"毛绒玩具",102.45));
          products.add(new Product(102,"笔记本",8.50));
          products.add(new Product(103,"签字笔",5.43));
          products.add(new Product(104,"文具盒",53.45));
          products.add(new Product(105,"背包",346.50));
          System.out.println(products);

          //2
          products.add(new Product(106,"Test",100.50));
          products.add(new Product(106,"Test",100.50));
          System.out.println(products);

          //3
          Iterator<Product> it = products.iterator();
          while (it.hasNext()) {
              Product pro = it.next();
              System.out.println(pro);
          }

          //4
          Iterator<Product> its = products.iterator();
          while (its.hasNext()) {
              Product pro = its.next();
              if (pro.getProductprice() > 300) {
                  ArrayList<Product> list = new ArrayList<>();
                  list.add(pro);
                  System.out.println(list);
              }
          }
    }
}
